home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1999 Spring / macformat-077.iso / Shareware Plus / Development / Akua Sweets 131 / Akua Sweets Examples / Finder / System Folder Order < prev    next >
Encoding:
Text File  |  1999-03-04  |  7.3 KB  |  215 lines  |  [TEXT/ToyS]

  1. (*
  2.  Version 1.07
  3.  
  4.  History
  5.  Ver Who When     What
  6.  107 GOD 13.03.98 Use Akua Sweets V1.2 to speed things up (set Finder info for)
  7.  106 GOD 25.01.98 Move "Text Encodings" to the left side, add flag to move "At Ease" to left side
  8.  105 GOD 12.08.97 Add "Scripting Additions" and "Bride" for MacOS 8/8.01
  9.  104 GOD 08.05.97 Support new names of German disabled folders under MacOS 7.6 / Extensions Manager 4
  10.                               Support "Text Encodings"
  11.  103 GOD 01.02.97 Support German System Folders, support invisibles with a beep
  12.                               Support dropped-on System Folders
  13.  102 GOD 25.01.97 Support "At Ease" items
  14.  101 GOD 18.01.97 Add "Desktop Printers" and "Launcher Items" to system folders list
  15. *)
  16.  
  17. -- Boolean options
  18. property kapUseFinder : true
  19. property kapAtEaseAtLeft : true
  20.  
  21. -- View for the System Folder (Small Snap-To-Grid Icons)
  22. property kapSystemFolderView : 334
  23.  
  24. -- A "+" as an item name creates a space in the positioning
  25.  
  26. -- Items considered system folders in the order of display
  27. property kapSysFolders : {"+", "Apple-Menü", "Apple Menu Items", "Application Support", "Ausschaltobjekte", "ColorSync Profiles", "Contextual Menu Items", "Control Panels", "Control Strip Modules", "Desktop Printers", "Editors", "Extensions", "Fonts", "KlickStarter-Objekte", "Kontrolleistenmodule", "Kontrollfelder", "Launcher Items", "PowerTalk Data", "Preferences", "PrintMonitor-Dokumente", "PrintMonitor Documents", "Scripting Additions", "Shutdown Items", "Startobjekte", "Startup Items", "Systemerweiterungen", "Text Encodings", "Zeichensätze"}
  28.  
  29. -- Items considered system folders for disabled items and AtEase items in reverse alphabetical order - since this is reversed
  30. property kapSysFoldDis : {"Systemordner (Aus)", "Systemerweiterungen (Aus)", "System Folder (Disabled)", "System Extensions (Disabled)", "Startup Items (Disabled)", "Startobjekte (Aus)", "Shutdown Items (Disabled)", "Kontrolleistenmodule (Aus)", "Kontrollfelder (Aus)", "Fonts (Disabled)", "Extensions (Disabled)", "Control Strip Modules (Dis.)", "Control Panels (Disabled)", "Apple Menu Items (Disabled)", "Ausschaltobjekte (Aus)"}
  31.  
  32. -- Items considered to be system extras (e.g. AtEase)
  33. property kapAtEaseItems : {"At Ease", "At Ease Help", "At Ease Hilfe", "At Ease Items", "At Ease Objekte", "Geschützte Objekte"}
  34.  
  35. -- Items considered system files
  36. property kapSysItems : {"System", "Finder", "MacsBug", "StartupScreen", "StartupScreen 0", "StartupScreen 1", "+", "Albumdatei", "Clipboard", "Hosts", "MacTCP DNR", "Note Pad File", "Scrapbook File"}
  37.  
  38. -- Spacing for columns and rows
  39. property kapPosX : 0
  40. property kapPosY : 0
  41. property kapSpaceY : 18
  42. property kapSpaceX : 132
  43.  
  44.  
  45. on run
  46.     open {path to system folder}
  47. end run
  48.  
  49.  
  50. on open fsObjs
  51.     repeat with fsObj in fsObjs
  52.         set sysPath to fsObj
  53.         set sysPathStr to (sysPath as string)
  54.         
  55.         if (kapUseFinder) then ¬
  56.             tell application "Finder" to reveal ((sysPathStr & "System") as alias)
  57.         
  58.         -- Set Small Snap-To-Grid View
  59.         SetView(sysPath, kapSystemFolderView)
  60.         
  61.         -- Do the items we know of (column 1 of folder)    
  62.         set kapPosX to 0 -- go to top of first column
  63.         set kapPosY to kapSpaceY
  64.         set pendingSpace to false
  65.         set sysItems to kapSysItems
  66.         
  67.         -- Add AtEase to system stuff (with a spacing)?
  68.         if (kapAtEaseAtLeft) then set sysItems to sysItems & {"+"} & kapAtEaseItems
  69.         
  70.         repeat with sysItem in sysItems
  71.             -- Do the System Items
  72.             if (character 1 of sysItem is "+") then
  73.                 set pendingSpace to true
  74.             else if (the kind of entry in sysPath named sysItem) is not nothing then
  75.                 if pendingSpace then set kapPosY to kapPosY + kapSpaceY
  76.                 set pendingSpace to false
  77.                 SetPosition((sysPathStr & sysItem) as alias, kapPosX, kapPosY, 1)
  78.                 set kapPosY to kapPosY + kapSpaceY
  79.             end if
  80.         end repeat
  81.         
  82.         set pendingSpace to false
  83.         
  84.         repeat with sysItem in kapSysFolders
  85.             -- Do the System Folders
  86.             if (character 1 of sysItem is "+") then
  87.                 set pendingSpace to true
  88.             else if (the kind of entry in sysPath named sysItem) is not nothing then
  89.                 if pendingSpace then set kapPosY to kapPosY + kapSpaceY
  90.                 set pendingSpace to false
  91.                 SetPosition((sysPathStr & sysItem) as alias, kapPosX, kapPosY, 2)
  92.                 set kapPosY to kapPosY + kapSpaceY
  93.             end if
  94.         end repeat
  95.         
  96.         -- go to bottom of second column
  97.         set kapPosX to kapPosX + kapSpaceX
  98.         set kapPosY to kapPosY - kapSpaceY
  99.         SetWindowSize(sysPath, kapPosX + kapSpaceX + kapSpaceX, kapPosY + kapSpaceY + kapSpaceY)
  100.         set pendingSpace to false
  101.         set sysItems to kapSysFoldDis
  102.         
  103.         -- Add AtEase at top of disabled stuff (with a spacing)?
  104.         if (not kapAtEaseAtLeft) then ¬
  105.             set sysItems to sysItems & {"+"} & asReverseList(kapAtEaseItems)
  106.         
  107.         repeat with sysItem in sysItems
  108.             -- Do the System Disabled Folders
  109.             if (character 1 of sysItem is "+") then
  110.                 set pendingSpace to true
  111.             else if (the kind of entry in sysPath named sysItem) is not nothing then
  112.                 if pendingSpace then set kapPosY to kapPosY + kapSpaceY
  113.                 set pendingSpace to false
  114.                 set labelIdx to 2
  115.                 if (sysItem contains "(") then set labelIdx to 6
  116.                 SetPosition((sysPathStr & sysItem) as alias, kapPosX, kapPosY, labelIdx)
  117.                 set kapPosY to kapPosY - kapSpaceY
  118.             end if
  119.         end repeat
  120.         
  121.         -- DO the items we don't know of
  122.         set kapPosX to kapSpaceX
  123.         set kapPosY to kapSpaceY
  124.         
  125.         set sysItems to the entries in sysPath
  126.         set orderedItems to (kapSysFoldDis & kapSysFolders & kapSysItems & kapAtEaseItems)
  127.         
  128.         repeat with fsName in sysItems
  129.             -- Not already positioned?
  130.             if (fsName is not in orderedItems) then
  131.                 SetPosition((sysPathStr & fsName) as alias, kapPosX, kapPosY, 3)
  132.                 set kapPosY to kapPosY + kapSpaceY
  133.             end if
  134.         end repeat
  135.     end repeat
  136. end open
  137.  
  138.  
  139.  
  140. on ReverseList(aList)
  141.     set revList to {}
  142.     set iCnt to count (items of aList)
  143.     
  144.     repeat with i from iCnt to 1 by -1
  145.         set revList to revList & {item i of aList}
  146.     end repeat
  147.     
  148.     return revList
  149. end ReverseList
  150.  
  151.  
  152.  
  153. on SetPosition(fsObj, x, y, labelNum)
  154.     -- Set the position of a file's icon in a folder to x,y
  155.     if (kapUseFinder) then
  156.         -- try
  157.         tell application "Finder"
  158.             reveal fsObj
  159.             set the position of fsObj to {x, y}
  160.             set the label index of fsObj to labelNum
  161.         end tell
  162.         -- on error
  163.         -- end try
  164.     else
  165.         set fInfo to the extended info for fsObj
  166.         set finder location of fInfo to {x, y}
  167.         set label number of fInfo to labelNum
  168.         set the catalog info of fsObj to fInfo
  169.     end if
  170. end SetPosition
  171.  
  172.  
  173.  
  174. on SetView(fsObj, viewConstant)
  175.     -- Set the view of a folder
  176.     if (kapUseFinder) then
  177.         -- try
  178.         tell application "Finder"
  179.             open {fsObj}
  180.             -- set the view of fsObj to viewConstant
  181.         end tell
  182.         -- on error
  183.         -- end try
  184.     else
  185.         set fInfo to the extended info for fsObj
  186.         set finder view setting of fInfo to viewConstant
  187.         set the catalog info of fsObj to fInfo
  188.     end if
  189. end SetView
  190.  
  191.  
  192.  
  193. on SetWindowSize(fsObj, dX, dY)
  194.     -- Set the size of a folder's window to dx,dy
  195.     if (kapUseFinder) then
  196.         -- try
  197.         tell application "Finder"
  198.             open fsObj
  199.             set newBox to (bounds of container window of fsObj)
  200.             set item 3 of newBox to (item 1 of newBox) + dX
  201.             set item 4 of newBox to (item 2 of newBox) + dY
  202.             set bounds of container window of fsObj to newBox
  203.         end tell
  204.         -- on error
  205.         -- end try
  206.     else
  207.         set fInfo to the extended info for fsObj
  208.         set newBox to finder window box of fInfo
  209.         set item 3 of newBox to (item 1 of newBox) + dX
  210.         set item 4 of newBox to (item 2 of newBox) + dY
  211.         set finder window box of fInfo to newBox
  212.         set the catalog info of fsObj to fInfo
  213.     end if
  214. end SetWindowSize
  215.